<%@ page language="java" import="com.alibaba.fastjson.JSONArray" pageEncoding="UTF-8" %>
<%@ page import="com.alibaba.fastjson.JSONObject" %>
<%@ page import="okhttp3.*" %>
<%--测试接口--%>
<%
    JSONObject jsonData = new JSONObject();
    JSONObject paramJson = new JSONObject();
    JSONArray detailList = new JSONArray();
    JSONObject detailJson = new JSONObject();
    detailJson.put("wbid","123");
    detailJson.put("csjc","asdf");
    detailJson.put("csmc","test");
    detailList.add(detailJson);
    JSONObject dataJson = new JSONObject();
    dataJson.put("Details",detailList);
    JSONObject DataJson = new JSONObject();
    DataJson.put("Data",dataJson);
    paramJson.put("data",DataJson);
    String returnStr = sendOKHttp3Request(paramJson.toJSONString());
    jsonData.put( "result", returnStr );
    out.print( jsonData.toJSONString() );
%>
<%!
    public static String sendOKHttp3Request(String paramJson){
        String result = "";
        try {
            OkHttpClient client = new OkHttpClient().newBuilder()
                    .build();
            MediaType mediaType = MediaType.parse("text/plain");
            RequestBody body = RequestBody.create(mediaType, "");
            String url = "http://58.241.13.10:11895/Api/PutData/ExecProcedureWithReturnJsonError";
            String dataflow = "dataflow=泛微oa→RZERPv4_铁建工科";
            String actionCode = "actionCode=put_csxxb";

            String data = "&data="+paramJson;
            Request request = new Request.Builder()
                    .url(url+"?"+dataflow+"&"+actionCode+"&"+data)
                    .method("POST", body)
                    .addHeader("Accept", "*/*")
                    .build();
            Response response = client.newCall(request).execute();
            result = response.body().string();
        }catch (Exception e){
            e.printStackTrace();
        }

        return result;
    }
%>





